<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateStoreCouponUserTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('store_coupon_users', function (Blueprint $table) {
            $table->id()->comment('优惠券用户领取记录表');
            $table->integer('cid')->index()->comment('兑换的项目id');
            $table->integer('user_id')->index()->comment('优惠券所属用户');
            $table->string('coupon_title')->comment('优惠券名称');
            $table->decimal('coupon_price',10,2)->comment('优惠券的面值');
            $table->decimal('use_min_price',10,2)->comment('最低消费多少金额可用优惠券');
            $table->timestamp('add_time')->comment('优惠券开始使用时间');
            $table->timestamp('end_time')->comment('优惠券结束使用时间');
            $table->timestamp('use_time')->comment('使用时间');
            $table->string('type')->comment('获取方式 0:后台发放 1:前台手动领取');
            $table->string('status',16)->comment('状态（status_one：未使用，status_two：已使用, status_three:已过期）');
            $table->tinyInteger('is_fail')->comment('是否有效:0无效 1有效(默认)');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('store_coupon_user');
    }
}
